import pymysql
import time

while True:
    host = "gz-cdbro-jhhihuc1.sql.tencentcdb.com"
    username = "wangzhijing"
    password = "ONSzyDLr"
    dbname = "pay_chaomeng"
    port = 63950
    db = pymysql.connect(host, username, password, dbname, port)
    cursor = db.cursor()
    x = str(input("请输入要查询appid的sn："))
    if 11 < len(x) < 24:
        sql = "SELECT card_id, uid, shop_id, code_id, salesman_id FROM hardware_list WHERE card_id='" + x + "'"
        cursor.execute(sql)
        result = cursor.fetchall()
        print(str(result).strip("((),)").replace("'", ""))
        db.close()
        time.sleep(20)
        break
    else:
        print("输入错误，重新输入！")
        continue
